﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BranchMangerOLD.aspx.cs" Inherits="TaoSH.View.BranchMangerOLD" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>机构管理</title>
            <link rel="stylesheet" href="../../CSS/bootstrap/css/bootstrap.css" />
    <link rel="stylesheet" href="../../JqueryPlug/jOrgChart/css/jquery.jOrgChart.css" />
    <!-- jQuery includes -->
    <script type="text/javascript" src="../../Scripts/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="../../CSS/bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript" src="../../JqueryPlug/jOrgChart/jquery.jOrgChart.js"></script>
    <style type="text/css">
        /* The node */
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#toolbtns .btn").fadeOut();
            //添加部门
            $("#btnaddJG").click(function () {
                var BranchCode = $(".jOrgChartSelect").attr("liid");
                MyDialog.btview("添加部门", $(".divAddBranch").clone().show(), "确认添加", function () {
                    var BranchName = $(".txtBranchName").val();
                    var ChargePeople = $(".txtBranchChargePeople").val();
                    $.ajax({
                        type: "GET",
                        url: "AdminHandle.ashx",
                        dataType: "html",
                        data: { "Action": "addBranch", "BranchName": BranchName, "ChargePeople": ChargePeople, "PBranchCode": BranchCode },
                        beforeSend: function (XMLHttpRequest) {
                            MyDialog.Mytips();
                        },
                        success: function (msg) {
                            var newbcode = msg;
                            if ($("#" + BranchCode).find("ul").length >= 1) {
                                $("#" + BranchCode + " ul").eq(0).append("<li id='" + newbcode + "'>" + BranchName + "</li>");
                            }
                            else {
                                $("#" + BranchCode).append("<ul><li  id='" + newbcode + "'>" + BranchName + "</li> </ul>");
                            }
                            initjgt();
                            MyDialog.CloseMytips();
                            MyDialog.alertTip('添加部门成功');
                        }
                    });


                });

            });
            initjgt();

        });

        function initjgt() {
            $("#org").jOrgChart();
            $(".node").click(function () {
                if ($(this).hasClass("jOrgChartSelect")) {

                }
                $(".node").css("background-color", "#FCF0C1").removeClass("jOrgChartSelect");

                $(this).css("background-color", "#b3cf6f").addClass("jOrgChartSelect");
                $("#toolbtns .btn").fadeIn();
                $("#pseltext").text("当前选中机构为:" + $(this).text());
                $("#hidseljgid").val($(this).attr("liid"));
            })
        }
    </script>
</head>
<body style="background: #eee; background-image: url(../../Images/furley_bg.png);
    background-position: initial initial; background-repeat: initial initial;">
    <form  runat="server">
    <div class="well-large" style="text-align: right; height: 30px; border:0px" id="toolbtns">
        <p class="text-info text-left pull-left" id="pseltext">
        </p>
        <button class="btn  btn-success" type="button" id="btnaddJG">
            添加机构</button>
        <button class="btn  btn-success" type="button">
            管理机构人员</button>
        <asp:Button ID="btndelJG" runat="server" Text="删除机构"  class="btn  btn-danger" OnClick="btndelJG_Click"/>
    </div>
    <div class="container-fluid">
        <ul id="org" style="display: none">
            <li id="1">组织机构
                <%=GetChiMenuByUserName(1)%>
            </li>
        </ul>
        <div id="chart"   class="well-large" style="overflow:auto; min-height:500px"> 
            
        </div>
    </div>
    <div class="divAddBranch well-large" style="display: none">
        <fieldset>
            <legend>添加部门</legend>
            <label>
                部门名称</label>
            <input type="text" class="txtBranchName">
            <label>
                部门负责人</label>
            <input type="text" class="txtBranchChargePeople">
        </fieldset>
    </div>
    <input type="hidden"  value="" id="hidseljgid" runat="server"/>
                <script type="text/javascript" src='../../JqueryPlug/lhgdialog/lhgdialog.js?self=true&skin=idialog'></script>
        </form>

</body>
</html>
